﻿using System;
using System.Collections.Generic;
using RenRen.Schema;
using RenRen.Session;
using RenRen.Utility;

namespace RenRen.Rest {
    /// <summary>
    /// RenRen Admin API 方法
    /// </summary>
    public class Admin : RestBase {
        /// <summary>
        ///  
        /// </summary>
        /// <param name="session">当前会话对象</param>
        public Admin(RenRenSession session)
            : base(session) {
        }

  
        /// <summary>
        /// 得到一个应用当天可以发送的通知和邀请的配额 
        /// </summary>
        public admin_getAllocation_response GetAllocation() {
            return GetAllocation(false, null, null);
        }

        /// <summary>
        /// 得到一个应用当天可以发送的通知和邀请的配额 
        /// </summary>
        /// <param name="callback">异步回调代理</param>
        /// <param name="state">异步请求状态信息对象</param>
        public void GetAllocationAsync(GetAllocationCallback callback, Object state) {
            GetAllocation(true, callback, state);
        }

 
        private admin_getAllocation_response GetAllocation(bool isAsync, GetAllocationCallback callback, Object state) {
            var parameterList = new Dictionary<string, string> { { "method", "xiaonei.admin.getAllocation" } };
            if (isAsync) {
                SendRequestAsync<admin_getAllocation_response, admin_getAllocation_response>(parameterList,HasSession, new RenRenCallCompleted<admin_getAllocation_response>(callback), state);
                return null;
            }

            var response = SendRequest<admin_getAllocation_response>(parameterList,HasSession);
            return response;
        }
  
        /// <summary>
        /// 异步回调GetAllocation代理   
        /// </summary>
        /// <param name="allocation">current allocation limit</param>
        /// <param name="state">An object containing state information for this asynchronous request</param>
        /// <param name="e">Exception object, if the call resulted in exception.</param>
        public delegate void GetAllocationCallback(admin_getAllocation_response allocation, Object state, RenRenException e);

    }
}